-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		velox
-- Create date: 2014-11-3
-- Description:	Get Hybridization sow basic information, such as pigpenName,feedername and pigTypeName of sow
-- =============================================
IF exists (select * from sysobjects where id = object_id('GetHybridizationSowBasicInfo_Proc'))
	drop PROCEDURE "dbo"."GetHybridizationSowBasicInfo_Proc"
Go
CREATE PROCEDURE GetHybridizationSowBasicInfo_Proc 
	-- Add the parameters for the stored procedure here
	@hoggeryId int, 
	@sowId uniqueidentifier
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	SET NOCOUNT ON;
	SELECT pp.CustomizeID,f.FeederName,pb.TypeName FROM Sow s 
		LEFT JOIN PigPen pp
			ON s.PigPenID=pp.PigPenID
		LEFT JOIN Feeders f
			ON f.FeederID=pp.FeederID
		LEFT JOIN PigBreed pb
			ON s.TypeID=pb.TypeID
		WHERE s.HoggeryID=@hoggeryId and s.SowID=@sowId and s.IsInFarm=1 
END
GO
